home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TypeLsItr.cpp
-
- Contains: Implementation of class ODTypeListIterator
-
- Owned by: Craig Carper
-
- Copyright: © 1994, 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 5/24/96 jpa 1246074: SOM_CATCH --> SOM_TRY..SOM_ENDTRY
-
- To Do:
- In Progress:
-
- */
-
- #define VARIABLE_MACROS
-
- #define ODTypeListIterator_Class_Source
- #include <TypLsItr.xih>
-
- #ifndef SOM_ODTypeList_xh
- #include <TypeList.xh>
- #endif
-
- #ifndef SOM_ODObject_xh
- #include <ODObject.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Errors_defined
- #include <ErrorDef.xh>
- #endif
-
- #ifndef _ORDCOLL_
- #include <OrdColl.h>
- #endif
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- #ifndef _ISOSTR_
- #include <ISOStr.h>
- #endif
-
- #ifndef _ODMEMORY_
- #include <ODMemory.h>
- #endif
-
- #ifndef _ODNew_
- #include <ODNew.h>
- #endif
-
- #pragma segment ODTypeListIterator
-
- //==============================================================================
- // ODTypeListIterator
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // ODTypeListIterator: somUninit
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODTypeListIteratorsomUninit(ODTypeListIterator *somSelf)
- {
- ODTypeListIteratorData *somThis = ODTypeListIteratorGetData(somSelf);
- ODTypeListIteratorMethodDebug("ODTypeListIterator","ODTypeListIteratorsomUninit");
-
- delete _fIterator;
-
- parent_somUninit(somSelf);
- }
-
- //------------------------------------------------------------------------------
- // ODTypeListIterator: InitODTypeListIterator
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK ODTypeListIteratorInitODTypeListIterator(ODTypeListIterator *somSelf, Environment *ev,
- ODTypeList* typeList)
- {
- ODTypeListIteratorData *somThis = ODTypeListIteratorGetData(somSelf);
- ODTypeListIteratorMethodDebug("ODTypeListIterator","InitODTypeListIterator");
-
- SOM_TRY
-
- /* Moved from somInit. SOM itself sets fields to 0
- _fTypeList = kODNULL;
- _fIterator = kODNULL;
- _fFirstCalled = kODFalse;
- */
-
- somSelf->InitObject(ev);
-
- _fTypeList = typeList;
- OrderedCollection* ordColl = _fTypeList->GetImplementation(ev);
- _fIterator = ordColl->CreateIterator();
-
- THROW_IF_NULL(_fIterator);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // ODTypeListIterator: IsNotComplete
- //------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK ODTypeListIteratorIsNotComplete(ODTypeListIterator *somSelf, Environment *ev)
- {
- ODTypeListIteratorData *somThis = ODTypeListIteratorGetData(somSelf);
- ODTypeListIteratorMethodDebug("ODTypeListIterator","IsNotComplete");
-
- if ( !_fFirstCalled )
- {
- ODSetSOMException(ev, kODErrIteratorNotInitialized);
- return kODFalse;
- }
-
- return _fIterator->IsNotComplete();
- }
-
- //------------------------------------------------------------------------------
- // ODTypeListIterator: First
- //------------------------------------------------------------------------------
-
- SOM_Scope ODType SOMLINK ODTypeListIteratorFirst(ODTypeListIterator *somSelf, Environment *ev)
- {
- ODTypeListIteratorData *somThis = ODTypeListIteratorGetData(somSelf);
- ODTypeListIteratorMethodDebug("ODTypeListIterator","First");
-
- ODType resultType = kODNULL; ODVolatile(resultType);
-
- SOM_TRY
-
- _fFirstCalled = kODTrue;
-
- ODType firstType = (ODType) _fIterator->First();
-
- if ( firstType )
- {
- ODULong strLength = ODISOStrLength((const ODISOStr) firstType);
- resultType = (ODType) ODNewPtrClear(strLength+1, kDefaultHeapID);
- ODISOStrNCopy((const ODISOStr) resultType, (ODISOStr) firstType, strLength);
- }
- SOM_CATCH_ALL
-
- ODDisposePtr(resultType);
-
- SOM_ENDTRY
-
- return resultType;
- }
-
- //------------------------------------------------------------------------------
- // ODTypeListIterator: Next
- //------------------------------------------------------------------------------
-
- SOM_Scope ODType SOMLINK ODTypeListIteratorNext(ODTypeListIterator *somSelf, Environment *ev)
- {
- ODTypeListIteratorData *somThis = ODTypeListIteratorGetData(somSelf);
- ODTypeListIteratorMethodDebug("ODTypeListIterator","Next");
-
- ODType resultType = kODNULL; ODVolatile(resultType);
-
- SOM_TRY
-
- _fFirstCalled = kODTrue;
-
- ODType nextType = (ODType) _fIterator->Next();
-
- if ( nextType )
- {
- ODULong strLength = ODISOStrLength((const ODISOStr) nextType);
- resultType = (ODType) ODNewPtrClear(strLength+1, kDefaultHeapID);
- ODISOStrNCopy((const ODISOStr) resultType, (ODISOStr) nextType, strLength);
- }
-
- SOM_CATCH_ALL
-
- ODDisposePtr(resultType);
-
- SOM_ENDTRY
-
- return resultType;
- }
-